﻿<?xml version="1.0" encoding="utf-8"?>
<UserControl
	x:Class="ICSharpCode.ILSpy.MainWindow"
	x:ClassModifier="public"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:tv="clr-namespace:ICSharpCode.TreeView;assembly=ICSharpCode.TreeView"
	xmlns:local="clr-namespace:ICSharpCode.ILSpy" xmlns:textView="clr-namespace:ICSharpCode.ILSpy.TextView"
	xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls"
	UseLayoutRounding="True"
	TextOptions.TextFormattingMode="Display"
	FocusManager.FocusedElement="{Binding ElementName=treeView}" Background="White">
    <UserControl.Resources>
		<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>
    <UserControl.CommandBindings>
		<CommandBinding
			Command="Open"
			Executed="OpenCommandExecuted" />
		<CommandBinding
			Command="Refresh"
			Executed="RefreshCommandExecuted" />
		<CommandBinding
			Command="Save"
			Executed="SaveCommandExecuted" />
		<CommandBinding
			Command="BrowseBack"
			CanExecute="BackCommandCanExecute"
			Executed="BackCommandExecuted" />
		<CommandBinding
			Command="BrowseForward"
			CanExecute="ForwardCommandCanExecute"
			Executed="ForwardCommandExecuted" />
		<CommandBinding
			Command="Search"
			Executed="SearchCommandExecuted" />
    </UserControl.CommandBindings>
	<DockPanel>
		<!-- Main menu -->
		<Menu DockPanel.Dock="Top" Name="mainMenu">
			<MenuItem Header="_File" /> <!-- contents of file menu are added using MEF -->
			<MenuItem Header="_View">
				<MenuItem Header="Show _internal types and members" IsCheckable="True" IsChecked="{Binding FilterSettings.ShowInternalApi}">
					<MenuItem.Icon>
						<Image Width="16" Height="16" Source="Images/PrivateInternal.png" />
					</MenuItem.Icon>
				</MenuItem>
			</MenuItem>
		</Menu>
		<!-- ToolBar -->
		<ToolBar
			Name="toolBar"
			DockPanel.Dock="Top">
			<ToolBar.Resources>
				<!-- Make images transparent if menu command is disabled -->
				<Style TargetType="{x:Type Image}">
					<Style.Triggers>
						<DataTrigger
							Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}"
							Value="False">
							<Setter Property="Opacity" Value="0.30" />
						</DataTrigger>
					</Style.Triggers>
				</Style>
			</ToolBar.Resources>
			<!-- 'Navigation' toolbar category is inserted here -->
			<Separator />
			<!-- 'Open' toolbar category is inserted here -->
			<Separator />
			<CheckBox IsChecked="{Binding FilterSettings.ShowInternalApi}" ToolTip="Show internal types and members">
				<Image Width="16" Height="16" Source="Images/PrivateInternal.png" />
			</CheckBox>
			<Separator />
			<ComboBox Name="languageComboBox" DisplayMemberPath="Name" Width="100"
			          ItemsSource="{x:Static local:Languages.AllLanguages}"
			          SelectedItem="{Binding FilterSettings.Language}" />
		</ToolBar>
		<!-- Main grid separating left pane (treeView) from main pane (textEditor) -->
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition
					Name="leftColumn"
					MinWidth="100"
					Width="0.4*" />
				<ColumnDefinition
					Width="3" />
				<ColumnDefinition
					Name="rightColumn"
					MinWidth="100"
					Width="0.6*" />
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition
					Height="*" />
			</Grid.RowDefinitions>
			<!-- Left pane: Tree View of assemblies and classes -->
			<tv:SharpTreeView
				Name="treeView"
				SelectionChanged="TreeView_SelectionChanged"
				ShowRoot="False"
				AllowDropOrder="True"
				AllowDrop="True" />
			<GridSplitter
				Grid.ZIndex="1"
				Grid.Column="1"
				Margin="-5,0"
				BorderThickness="5,0"
				HorizontalAlignment="Center"
				VerticalAlignment="Stretch"
				BorderBrush="Transparent" />
			<!-- Right pane: Text Editor -->
			<Grid Grid.Column="2">
				<Grid.ColumnDefinitions>
					<ColumnDefinition
						Width="*" />
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="0" Name="topPaneRow" />
					<RowDefinition Height="1" />
					<RowDefinition Height="0.7*" MinHeight="100" Name="textViewRow" />
					<RowDefinition Height="1" />
					<RowDefinition Height="0" Name="bottomPaneRow" />
				</Grid.RowDefinitions>
				<Border BorderBrush="Black" BorderThickness="1" Name="updateAvailablePanel" Visibility="Collapsed">
					<DockPanel>
						<Button DockPanel.Dock="Right" Click="updateAvailablePanelCloseButtonClick" MinWidth="0">X</Button>
						<StackPanel Orientation="Horizontal">
							<TextBlock Margin="4,0" VerticalAlignment="Center">A new ILSpy version is available.</TextBlock>
							<Button Click="downloadUpdateButtonClick">Download</Button>
						</StackPanel>
					</DockPanel>
				</Border>
				
				<controls:DockedPane x:Name="topPane" Grid.Row="1" Title="Top" Visibility="Collapsed" CloseButtonClicked="TopPane_CloseButtonClicked" />
				
				<GridSplitter
					Grid.ZIndex="1"
					Grid.Row="2"
					Margin="0,-2,0,-5"
					BorderThickness="0,2,0,5"
					BorderBrush="Transparent"
					HorizontalAlignment="Stretch"
					VerticalAlignment="Center"
					Visibility="{Binding Visibility, ElementName=topPane}" />
				
				<!-- decompilerTextView is into the mainPane by code -->
				<ContentPresenter Name="mainPane" Grid.Row="3"/>
				
				<GridSplitter
					Grid.ZIndex="1"
					Grid.Row="4"
					Margin="0,-2,0,-5"
					BorderThickness="0,2,0,5"
					BorderBrush="Transparent"
					HorizontalAlignment="Stretch"
					VerticalAlignment="Center"
					Visibility="{Binding Visibility, ElementName=bottomPane}" />
				
				<controls:DockedPane x:Name="bottomPane" Grid.Row="5" Title="Bottom" Visibility="Collapsed" CloseButtonClicked="BottomPane_CloseButtonClicked" />
			</Grid>
		</Grid>
	</DockPanel>
</UserControl>